package com.gibs.peixunapi.dao;

import java.util.List;

import com.gibs.peixunapi.model.ExamInfo;
import com.gibs.peixunapi.model.TestPaper;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.ExamClassInfo;

@Repository
public interface ExamClassInfoDao extends JpaRepository<ExamClassInfo, Integer>, JpaSpecificationExecutor<ExamClassInfo> {

	@Query("from ExamClassInfo where name = ?1")
	List<ExamClassInfo> find(String name);

	@Query("from ExamClassInfo where name like ?1")
	List<ExamClassInfo> findLike(String name);

	@Query(value = "select * from ExamClassInfo limit ?, ?", nativeQuery = true)
	List<ExamClassInfo> findPage(Integer offset, Integer size);

	@Query(value = "select * from ExamClassInfo where name = ? limit ?, ?", nativeQuery = true)
	List<ExamClassInfo> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from ExamClassInfo where name like ? limit ?, ?", nativeQuery = true)
	List<ExamClassInfo> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from ExamClassInfo where name = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from ExamClassInfo where name like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from ExamClassInfo order by id asc")
	List<ExamClassInfo> findAllAsc();

	@Query("select id from ExamClassInfo where examStatus = -1 and examInfoId in ?1")
	List<?> isExamClassStart(List<ExamInfo> examInfoId);
}

